Make SpirvValue(Kind) representation and operations more orthogonal and robust (lossless).#348
Make SpirvValue(Kind) representation and operations more orthogonal and robust (lossless).#348eddyb wants to merge 23 commits intoRust-GPU:mainfrom
SpirvValue(Kind) representation and operations more orthogonal and robust (lossless).#348Conversation
1e33b18 to
b4ed844
Compare
|
Tested on my nanite-at-home project, 3 runs, first run after branch switch discarded (due to many CPU crates recompiling), cmdline: older master 8ee9f2f: 16.3s 16.4s 16.6s This branch is slightly faster 🎉 |
Pull request was converted to draft
Wow, that's in the opposite direction from what I heard from @nazar-pc, but it's good to know it can swing either way. In the meanwhile, I really want to land certain soundness fixes in So I've marked this PR as draft, and I hope to come up with something isolated, and we can land this later. EDIT: the soundness fix PR is now up: |
b4ed844 to
e0ca2a2
Compare
71292fd to
ccb2e39
Compare
3dbaf18 to
e5b8b18
Compare
cd3ee54 to
8395cee
Compare
…] [2024] WIP: mem2reg unsound changes?
…nlined function.
… (as it'd require outside-in inlining).
… requires the preceding commit] linker/inline: don't rescan inlined callee blocks.
8395cee to
9f04dde
Compare
SpirvValue, and especiallySpirvValueKind, have been serving several purposes so far:struct SpirvValue { kind: SpirvValueKind, ty: ... }before this PR)SpirvConsts (already have some of that done for later PRs)SpirvValueKind::IllegalConst, aSpanisn't known initially at all(so there's a need to defer until the time of
SpirvValue::def, which may bring aSpan)SpirvValue::strip_ptrcastsundo pointer castsSpirvValueKind::LogicalPtrCastcontains the value and type IDs for aSpirvValue(
SpirvValue { kind: SpirvValueKind::Def(original_ptr), ty: original_ptr_ty })That has grown ad-hoc, and it can be a nightmare to extend any part of it, hence this work.
More specifically, this PR:
Spanat mostboolfield (zombie_waiting_for_span) replacesSpirvValueKind::IllegalConstSpirvValue::def(which is called everywhere to obtain a SPIR-V ID)only has to check a
bool(for registering theSpan), no more string formattingto generate the string message themselves, but it's unclear if that was ever skipped
(and I wasn't able to observe any change in build times, tho more testing is welcome)
SpirvValueKind::LogicalPtrCastwith an equivalentOptioninSpirvValueKind::DefSpirvValuegeneric and reusing it,SpirvValue::strip_ptrcastsbecomessimpler and combining it with
pointercastis now lossless (wrt other details)SpirvValuethat is simultaneously like the oldSpirvValueKind::IllegalConstandSpirvValueKind::LogicalPtrCastat the same time(arguably the main motivation for this PR, specifically as a
const_bitcastresult)SpirvValues in theSpirvConst<->SPIR-V ID "const interning" mapsSpirvValue's new generic param),this removes all duplicated logic around "deriving
SpirvValuefor a constant"(i.e. what used to decide whether
SpirvValueKind::IllegalConstshould be used)SpirvValue::const_fold_loadbecomes trivial, but even more important, lossless(returning the same exact
SpirvValueas the originalSpirvConstdid)